/*
@
@	Author: DarkLord
@	NPC = Arturo
@	Map =  Hidden-Street <Abandoned Tower <Determin to adventure> >
@	NPC MapId = 922011100
@	Function = Warp out of LPQ + Give Reward
@
*/
 
const int REWARDS = 59;

const int [] rewards = {
	2000002, //100 White Potions
	2000003, //100 Blue Potions
	2022003, //30 Unagis
	2000004, //10 Elixers
	4020002, //15 Aquamarine Ores
	4020000, //15 Garnet Ores
	4010002, //15 Mithril Ores
	4020005, //15 Sapphire Ores
	4010004, //15 Silver Ores
	4010001, //15 Steel Ores
	4020006, //15 Topaz Ores
	4003000, //50 Screws
	4010006, //5 Gold Ores
	4020007, //4 Diamond Ores
	4020008, //3 Black Crystal Ores
	2070011, //Maple Throwing-Stars
	1032013, //Red-Hearted Earrings
	1032012, //Skull Earrings
	1032011, //Blue Moon Earrings
	1102004, //Black Napoleon
	1102001, //Blue Napoleon
	1102000, //Green Napoleon
	1102002, //Red Napoleon
	1102003, //White Napoleon
	1102014, //Black Justice Cape
	1102011, //Blue Justice Cape
	1102012, //Red Justice Cape
	1102013, //White Justice Cape
	2040602, //10% Bottomwear DEF
	2040802, //10% Glove DEX
	2040002, //10% Helmet DEF
	2040402, //10% Topwear DEF
	2040505, //10% Overall DEF
	2040601, //60% Bottomwear DEF
	2044501, //60% Bow ATT
	2044701, //60% Claw ATT
	2044601, //60% Crossbow ATT
	2041019, //60% Cape DEX
	2041016, //60% Cape INT
	2041022, //60% Cape LUK
	2041013, //60% Cape STR
	2041007, //60% Cape HP
	2043301, //60% Dagger ATT
	2040301, //60% Earring INT
	2040801, //60% Gloves DEX
	2040001, //60% Helmet DEF
	2040004, //60% Helmet HP
	2040504, //60% Overall DEF
	2040501, //60% Overall DEX
	2040513, //60% Overall INT
	2043101, //60% One-Handed Axe ATT
	2044201, //60% Two-Handed BW ATT
	2044401, //60% Pole Arm ATT
	2040701, //60% Shoes DEX
	2044301, //60% Spear ATT
	2043801, //60% Staff MATT
	2040401, //60% Topwear DEF
	2043701, //60% Wand MATT
	2040803, //100% Gloves ATT
	};
const int [] amounts = {100, 100, 30, 10, 15, 15, 15, 15, 15, 15, 15, 50, 5, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};

void npc(Player @player, NPC @npc) {
	int state = npc.getState();
	if(state == 0){
		npc.addText("Incredible! You've cleared every stage and now you're here basking in your victory. Wow. I sincerely congratulate each and every one of you for the job well done, and here's a little present for you guys. Before taking it, please make sure your use inventory and your equipment inventory have a slot available.");
		npc.sendNext();
	}
	if(state == 1){
		if(player.checkSlot(EQUIP) && player.checkSlot(USE) && player.checkSlot(ETC)){
			int reward = random(REWARDS);
			player.giveItem(rewards[reward], amounts[reward]);
			player.changeMap(221024500);
			player.giveItem(4001022, -(player.getItemAmount(4001022)));
			player.giveItem(4001023, -(player.getItemAmount(4001023)));
			npc.end();
		}
		else{
			npc.addText("Your USE and ETC inventory need to have at least one empty slot available to receive your rewards. Please make the necessary adjustments and then talk to me.");
			npc.sendNext();
			npc.end();
		}
	}
}